package cn.codergege.demo.batch

import cn.codergege.demo.entity.Person
import org.slf4j.LoggerFactory
import org.springframework.batch.item.ItemProcessor


class PersonItemProcessor : ItemProcessor<Person, Person> {

    val log = LoggerFactory.getLogger(javaClass)

    @Throws(Exception::class)
    override fun process(person: Person): Person {
        val name = person.name.toUpperCase()
        val email = person.email?.toUpperCase()

        val transformedPerson = Person(null, name, null, null, email)

        log.info("Converting ($person) into ($transformedPerson)")

        return transformedPerson
    }

}